
package com.common.dto.base;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Transient;

import com.common.util.ConstantDefine;
import com.common.util.ShiroUtil;
import com.common.util.StringUtil;
import com.common.util.UUIDGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.web.multipart.MultipartFile;


public abstract class BaseDTO implements Serializable {
	@Transient
	private static final long serialVersionUID = 1L;
	/**主键*/
	@Id
	@GeneratedValue(generator = "UUID")
	protected String id;
	/**创建时间*/
	@Column(name="created_date")
	private Date createTime;
	/**创建人*/
	@Column(name="created_by")
	private String creator;
	@Column(name="updated_by")
	private String modifier;
	/**修改时间*/
	@Column(name="updated_date")
	private Date modifyTime;
	/**数据状态*/
	private String status="1"; //'状态 1=有效，0=失效，2=锁定',

	@Transient
	private String uuid=UUIDGenerator.getUUID();

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
	
	
	/**当前页码*/
	@Transient
	private int page=1;
	/**每页数量*/
	@Transient
	private int rows=10;
	/**开始日期，用作查询条件*/
	@Transient
	private Date startDate;
	/**结束日期，用作查询条件*/
	@Transient
	private Date overDate;
	/**用户编号，用作查询条件*/
	@Transient
	private String personCode;
	/**角色类型 用作查询条件 0:管理员，1:客户，2:配送员*/
	@Transient
	private String roleType;

	/**初始密钥*/
	@Transient
	private String initKey;

	/**搜索关键字*/
	@Transient
	private String key;

	/**条件查询预留字段*/
	@Transient
	private String param1;
	@Transient
	private String param2;
	@Transient
	private String param3;
	@Transient
	private String param4;
	@Transient
	private List<String> list;
	@Transient
	private String tableName;

	public String getParam4() {
		return param4;
	}

	public void setParam4(String param4) {
		this.param4 = param4;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public List<String> getList() {
		return list;
	}

	public void setList(List<String> list) {
		this.list = list;
	}

	public String getParam1() {
		return param1;
	}

	public void setParam1(String param1) {
		this.param1 = param1;
	}

	public String getParam2() {
		return param2;
	}

	public void setParam2(String param2) {
		this.param2 = param2;
	}

	public String getParam3() {
		return param3;
	}

	public void setParam3(String param3) {
		this.param3 = param3;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	/**设备密钥*/
	@Transient
	private String equipmentKey;

    /** 是否是查询：0否，1是 */
    @Transient
    private String isSearch = "0";

    public String getIsSearch() {
        return isSearch;
    }

    public void setIsSearch(String isSearch) {
        this.isSearch = isSearch;
    }
	
	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public String getRoleType() {
		return roleType;
	}

	public void setRoleType(String roleType) {
		this.roleType = roleType;
	}


	public String getMailContext() {
		return mailContext;
	}

	public void setMailContext(String mailContext) {
		this.mailContext = mailContext;
	}

	/**用户临时邮箱，用作通用发送邮件存储*/
	@Transient
	private String mailContext;

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	public Date getCreateTime() {
		return createTime;
	}
	
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	public Date getModifyTime() {
		return modifyTime;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	public Date getStartDate() {
		return startDate;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
	public Date getOverDate() {
		return overDate;
	}

	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	public void setOverDate(Date overDate) {
		this.overDate = overDate;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getCreator() {
		
		return creator;
	}
	public void setCreator(String creator) {
		this.creator = creator;
	}
	public String getModifier() {
		return modifier;
	}
	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	public String getPersonCode() {
		return personCode;
	}
	public void setPersonCode(String personCode) {
		this.personCode = personCode;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Override
	public String toString() {
		return "BaseDTO [id=" + id + ", createTime=" + createTime
				+ ", creator=" + creator + ", modifier=" + modifier
				+ ", modifyTime=" + modifyTime + ", status=" + status
				+ ", startDate=" + startDate + ", overDate=" + overDate
				+ ", personCode=" + personCode + ", roleType=" + roleType
				+ ", mailContext=" + mailContext + "]";
	}

	public String getInitKey() {
		return initKey;
	}

	public void setInitKey(String initKey) {
		this.initKey = initKey;
	}

	public String getEquipmentKey() {
		return equipmentKey;
	}

	public void setEquipmentKey(String equipmentKey) {
		this.equipmentKey = equipmentKey;
	}


	public void fastCreate(){
		String currentUser = ShiroUtil.getSessionByKey(ConstantDefine.PERSONCODE_SESSION).toString();
		currentUser = StringUtil.isEmpty(currentUser)? "SYSTEM" :currentUser;
		setId(UUIDGenerator.getUUID());
		setCreateTime(new Date());
		setModifyTime(new Date());
		setModifier(currentUser);
		setCreator(currentUser);
	}

	public void fastModify(){
		String currentUser = ShiroUtil.getSessionByKey(ConstantDefine.PERSONCODE_SESSION).toString();
		currentUser = StringUtil.isEmpty(currentUser)? "SYSTEM" :currentUser;
		setModifyTime(new Date());
		setModifier(currentUser);
	}

	public void setNullStatus(){
		this.status = null;
	}

	


	

}
